<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //异步编程 文件操作 网络操作（Ajax ，request）数据库操作
        // 1s后控制台输出111 2s后输出222 3s后输出 333
        function one(){
            setTimeout(()=>{
                console.log(1111);
                it.next();
            },1000);
        }

        function two(){
            setTimeout(()=>{
                console.log(2222);
                it.next();
            },2000)
        }

        function three(){
            setTimeout(()=>{
                console.log(3333);
                it.next();
            },3000)
        }

        function * gen(){
            yield one();
            yield two();
            yield three();
        }
        let it = gen();
        it.next();

    </script>
</body>
</html>